<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateInverterDatasFour extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('inverter_datas_four_begin_2019_05_05', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('device_id');
            $table->integer('site_id');
            $table->integer('user_id');

            //device params
            $table->double('DCU1');
            $table->double('DCI1');
            $table->double('DCU2')->nullable();
            $table->double('DCI2')->nullable();
            $table->double('DCU3')->nullable();
            $table->double('DCI3')->nullable();
            $table->double('DCU4')->nullable();
            $table->double('DCI4')->nullable();

            $table->double('ACUA')->nullable();
            $table->double('ACIA')->nullable();
            $table->double('ACUB')->nullable();
            $table->double('ACIB')->nullable();
            $table->double('ACUC')->nullable();
            $table->double('ACIC')->nullable();

            $table->double('IVTemp');
            $table->double('TotGenCap');
            $table->integer('IVStatus');
            $table->integer('IVError');
            $table->integer('IVMode');
            $table->double('FR');

            $table->integer('IVRun')->nullable();
            $table->integer('YearGenCap')->nullable();
            $table->integer('MonthGenCap')->nullable();
            $table->integer('LastMonthGenCap')->nullable();
            $table->double('DayGenCap')->nullable();
            $table->double('LastDayGenCap')->nullable();

            $table->double('PowerLimitPercent')->nullable();
            $table->integer('ActivePower')->nullable();
            $table->integer('ReactivePower')->nullable();
            $table->integer('ApparentPower')->nullable();
            $table->double('PowerFactor')->nullable();
            $table->double('BoardTemp1')->nullable();
            $table->double('BoardTemp2')->nullable();

            $table->integer('IVType')->nullable();
            $table->dateTime('EventTime')->nullable();
            $table->integer('EventType')->nullable();
            $table->index('EventTime');

            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('inverter_datas_four_begin_2019_05_05');
    }
}
